import React, { Component } from 'react'
import { connect } from 'dva';
import FormList from '../components/FormItem';

interface Props {
  dispatch: Function,
  data: {
    id: number
  },
  match: {
    params: {
      id: number
    }
  },
  details: object
}

const Keys = [
  'id',
  'name',
  'buildFireLevel',
  'fireDangerLevel',
  'address',
  'quantity',
  'dutyName',
  'floorSpace',
  'height',
  'reason',
  'fireSignSituation',
  'dangerSituation',
  'fireSituation',
  'flag',
  'remark',
  'buildId',
  'floorId',
  'areaId',
  'buildName',
  'floorName',
  'areaName',
  'fireDeviceType',
  'fireDeviceTypeName',
];

@connect(({ archives_point }) => ({
  data: archives_point.editDetails
}))
class Update extends Component<Props, any> {

  componentDidMount() {
    const { dispatch, match } = this.props;
    const { params } = match;

    dispatch({
      type: 'archives_point/queryEditInfoById',
      payload: {
        id: params.id,
        keys: Keys
      }
    })
  }

  render() {
    return (
      <section className="edit">
        <FormList data={this.props.data} key={Date.now()} />
      </section>
    );
  }
}

export default Update;
